package com.test.utils;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.LogoutFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 自定义LogoutFilter
 * Created by Lenovo on 2019/1/10.
 */
public class SystemLogoutFilter extends LogoutFilter {

    @Override
    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
        Subject subject = getSubject(request,response);
        String redirectURL = getRedirectUrl(request,response,subject);
        try {
            subject.logout();
        }catch (Exception e){
            e.printStackTrace();
        }
        issueRedirect(request,response,redirectURL);
        return false;
    }

    public static void main(String[] args) {
            System.out.println(DigestUtils.md5Hex("admin"));
    }
}
